package org.kinglone.back.classify.model;

import org.hibernate.annotations.GenericGenerator;
import org.kinglone.back.article.model.Article;
import org.kinglone.back.comment.model.Comment;
import org.kinglone.common.util.DateUtil;
import org.kinglone.common.util.DateUtils;

import javax.persistence.*;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;


/**
 * 分类实体类   与文章一对多
 * @author yejinlong
 * 2017年8月2日
 * @version 1.0
 */
@Entity 
@Table(name="classify")
public class Classify implements Serializable{


	private static final long serialVersionUID = 1L;	
	@Id @GenericGenerator(name = "generator", strategy = "uuid.hex")
	@GeneratedValue(generator = "generator")
	@Column(name="sysid", unique = true, nullable = false, length = 32)
	private String sysid;
	
	//分类名称
	@Column(name="classifyName",nullable = false,length=32)
	private String classifyName;
	
	//创建时间
	@Column(name="createtime",nullable = false, length = 19)
	private Date createTime;
	
	//在一的一方配置@OneToMany(mappedBy="department")，将维护权交由多的一方来维护；
/*	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "classify")
	private Set<Article> articles = new HashSet<Article>(0);*/

	public Classify() {
	}

	public Classify(String sysid, String classifyName, Date createTime) {
		super();
		this.sysid = sysid;
		this.classifyName = classifyName;
		this.createTime = createTime;
	}

	public String getSysid() {
		return sysid;
	}

	public void setSysid(String sysid) {
		this.sysid = sysid;
	}

	public String getClassifyName() {
		return classifyName;
	}

	public void setClassifyName(String classifyName) {
		this.classifyName = classifyName;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}


	@Transient
	public String getTimeStr(){		
		
	    return DateUtil.dateToString(this.getCreateTime(),"yyyy-MM-dd HH:mm:ss");
	}


}
